import os
path = 'data2/'
path2 = 'data/'

f3 = open('data_list.txt', 'w', encoding='utf-8')
for home, _, files in os.walk(path):

    for filename in files:
        fullname = os.path.join(home, filename)
        f = open(fullname, 'r', encoding='utf-8')
        new_name = filename.replace('fjs', 'txt')
        if 'edata' in home:
            new_name = 'e_' + new_name
        elif 'rdata' in home:
            new_name = 'r_' + new_name
        elif 'sdata' in home:
            new_name = 's_' + new_name
        elif 'vdata' in home:
            new_name = 'v_' + new_name
        f3.write(new_name + '\n')
        f2 = open(path2 + new_name, 'w', encoding='utf-8')
        s = f.readlines()
        for i in range(len(s)):
            tmp = s[i].split()
            if i == 0:
                f2.write(tmp[0] + ' ' + tmp[1] + ' ' + tmp[2] + '\n')
            else:
                f2.write(' '.join(tmp) + '\n')
